function enterSumbit(){  
    var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异  
   if (event.keyCode == 13){  
	   systemLogin();
   }  
} 

function isEmail(str){
	var reg = /^([a-zA-Z0-9_-]|[.])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	return reg.test(str);
} 

function isMobile(str){
	var reg = /^((\+?86)|(\(\+86\)))?1\d{10}$/; 
	return reg.test(str);
}

function inputClean(){
	$('#userName').attr("value","");
}

function verifyUser(){
	$("#errmsg").empty();
	var param =$.serializeObject($('#userRegisterForm'));
	var userName = param["userName"];
	if(userName == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}else{
		if(!isMobile(userName)){
			$("#errmsg").append("<font color=red> 您的用户名格式不正确，请仔细填写!</font>");
			$("#userName").focus();
			return;
		}
	}
	$.ajax({
		url: path+"/user/verifyUser.do?userName=" + userName,
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				$("#errmsg").append("<font color=red>" + result.msg+ "</font>" );
				$("#userName").focus();
			}else{
				$("#errmsg").append("<font color=red>" + result.msg + "</font>" );
			}
		}
	});
}

function verifyUser2(){
	$("#errmsg").empty();
	var param =$.serializeObject($('#userRegisterForm2'));
	var userName = param["userName"];
	if(userName == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}else{
		if(!isEmail(userName)){
			$("#errmsg").append("<font color=red> 您的用户名格式不正确，请仔细填写!</font>");
			$("#userName").focus();
			return;
		}
	}
	
	$.ajax({
		url: path+"/user/verifyUser.do",
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				$("#errmsg").append("<font color=red> 您的用户名重复!</font>");
				$("#userName").focus();
			}else{
				$("#errmsg").append("<font color=green> 您的用户名可用！</font>");
			}
		}
	});
}

function getVerifyMobileCode(){
	$("#errmsgImp").empty();
	var mob = $('#userName');
	var mobile = mob.val();
	if(!isMobile(mobile)){
		$("#errmsgImp").append("<font color=red> 您的电话号码格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	verifyUser();
	$.ajax({
		url: path+"/user/getVerifyMobileCode.do?mobile="+mobile,
		data: mobile,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				$("#errmsgImp").append("<font color=green>" + result.msg + "</font>");
				return true;
			}else{
				$("#errmsgImp").append("<font color=red>" + result.msg + "</font>");
				$("#verifyMobileCode").focus();
				return false;
			}
		}
	});
}

function reSetPasswordPage(){
	$("#errmsgImp").empty();
	var mob = $('#userName');
	var mobile = mob.val();
	if(!isMobile(mobile)){
		$("#errmsg").append("<font color=red> 您的电话号码格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	var codeinp = $('#verifyMobileCode');
	var verifyMobileCode = codeinp.val();
	verifyUser();
	$.ajax({
		url: path+"/user/verifyMobileCode.do?type=mobile&mobile="+mobile+"&verifyMobileCode="+verifyMobileCode,
		data: mobile,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				$("#errmsgImp").append("<font color=green>" + result.msg + "</font>");
				window.location=path+"/user/toReSetPasswordPage.do?type=mobile&mobile=" + mobile;
				return true;
			}else{
				$("#errmsgImp").append("<font color=red>" + result.msg + "</font>");
				$("#mobile").focus();
				return false;
			}
		}
	});
}


function reSetPasswordEmail(){
	$("#errEmail").empty();
	var param = $.serializeObject($('#emailForm'));
	var mail = param['userName'];
	if(!isEmail(mail)){
		$("#errEmail").append("<font color=red> 您的Email格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	$.ajax({
		url: path+"/user/toReSetPasswordSendEmail.do?email=" + mail,
//		url: path+"/user/verifyEmail.do?email=" + mail,
		data: mail,
		type:"POST",
		dataType:"json",
		success: function(result) {
			if(result.success){
				$("#errEmail").append("<font color=green>" + result.msg +  "</font>");
				//window.location=path+"/user/toReSetPasswordPage.do?type=email&email=" + mail;
				window.location=path+"/user/toSendEmailSuccess.do";
				$("#userName").focus();
				return true;
			}else{
				$("#errEmail").append("<font color=red>" + result.msg +  " </font>");
				$("#userName").focus();
				return false;
			}
		}	
	});
}

function reSetPasswordEnd(){
		$("#errmsgPwd").empty();
		var param =$.serializeObject($('#resetForm'));
		var password = param["userPassword"];
		var password2=param["userPassword2"];
		if(password == "" || password2 == ""){
			$("#errmsgPwd").append("<font color=red> 您的密码为空，请仔细填写!</font>");
			$("#userPassword").focus();
			return;
		}else{
			if (password != password2){
				$("#errmsgPwd").append("<font color=red> 您的密码不一致，请仔细填写!</font>");
				$("#userPassword2").focus();
				return;
			}
		}
		$.ajax({
			url: path+"/user/reSetPassword.do?password=" + password,
			data: param,
			type : "POST",
			dataType: "json",
			success: function(result) {
				if(result.success){
					$("#errmsgPwd").append("<font color=green>" + result.msg + "</font>");
					window.location=path+"/user/toRegisterSuccess.do";
				}else{
					document.getElementById('errmsgEnd').innerHTML = "<font color=red> " + result.msg + "</font>";
				}
			}
		});
}

function verifyMobileCode(){
	$("#errmsg").empty();
	var verifyMobileCode = $('#verifyMobileCode');
	$.ajax({
		url: path+"/user/verifyMobileCode.do",
		data: verifyMobileCode,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				$("#errmsg").append("<font color=green> 手机验证码正确！</font>");
				return true;
			}else{
				$("#errmsg").append("<font color=red> 手机验证码错误！</font>");
				$("#verifyMobileCode").focus();
				return false;
			}
		}
	});
}

function verifyCode(){
	$("#errmsg").empty();
	var verifyCode = $('#verifyCode');
	$.ajax({
		url: path+"/user/verifyCode.do",
		data: verifyCode,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				$("#errmsg").append("<font color=green> 验证码正确！</font>");
				return true;
			}else{
				$("#errmsg").append("<font color=red> 验证码错误！</font>");
				$("#verifyCode").focus();
				return false;
			}
		}
	});
}

function verifyCode2(){
	$("#errmsg").empty();
	var verifyCode = $('#verifyCode2');
	$.ajax({
		url: path+"/user/verifyCode.do",
		data: verifyCode,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				$("#errmsg").append("<font color=green> 验证码正确！</font>");
				return true;
			}else{
				$("#errmsg").append("<font color=red> 验证码错误！</font>");
				$("#verifyCode").focus();
				return false;
			}
		}
	});
}

function changeImage(){
	document.getElementById("verifyCodeImage").src=path + "/Kaptcha.jpg?"+Math.random();
//	$('verifyCodeImage').attr("src", path + "/Kaptcha.jpg?"+Math.random());
}

function mobileRegister(){
	$("#errmsg").empty();
	var param =$.serializeObject($('#userRegisterForm'));
	var userName = param["userName"];
	if(userName == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}else{
		if(!isMobile(userName)){
			$("#errmsg").append("<font color=red> 您的用户名格式不正确，请仔细填写!</font>");
			$("#userName").focus();
			return;
		}
	}
	var password = param["userPassword"];
	var password2=param["userPassword2"];
	if(password == "" || password2 == ""){
		$("#errmsg").append("<font color=red> 您的密码为空，请仔细填写!</font>");
		$("#userPassword").focus();
		return;
	}else{
		if (password != password2){
			$("#errmsg").append("<font color=red> 您的密码不一致，请仔细填写!</font>");
			$("#userPassword2").focus();
			return;
		}
	}
	verifyMobileCode();
	verifyCode();
	$.ajax({
		url: path+"/user/register.do",
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				window.location=path+"/user/toRegisterSuccess.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>";
			}
		}
	});
}

function mailRegister(){
	$("#errmsg").empty();
	var param =$.serializeObject($('#userRegisterForm2'));
	var userName = param["userName"];
	if(userName == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}else{
		if(!isEmail(userName)){
			$("#errmsg").append("<font color=red> 您的用户名格式不正确，请仔细填写!</font>");
			$("#userName").focus();
			return;
		}
	}
	var password = param["userPassword"];
	var password2=param["userPassword2"];
	if(password == "" || password2 == ""){
		$("#errmsg").append("<font color=red> 您的密码为空，请仔细填写!</font>");
		$("#userPassword").focus();
		return;
	}else{
		if (password != password2){
			$("#errmsg").append("<font color=red> 您的密码不一致，请仔细填写!</font>");
			$("#userPassword2").focus();
			return;
		}
	}
	verifyCode2();
	$.ajax({
		url: path+"/user/register.do?regType=mail",
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				alert("邮件发送成功，请进入邮箱进行验证。" + result.msg);
//				window.location=path+"/user/toRegisterSuccess.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>";
			}
		}
	});
}

function userLogin(){
	$("#errmsg").empty();
	var param =$.serializeObject($('#userLoginForm'));
	var userName = param["userName"];
	if(userName == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	if(param["userPassword"] == ""){
		$("#errmsg").append("<font color=red> 您的密码为空，请仔细填写!</font>");
		$("#userPassword").focus();
		return;
	}
	verifyCode();
	$.ajax({
		url: path+"/user/login.do",
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				window.location=path+"/user/toMain.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>, <font color=green> <a style='color:green' href='user/toReSetPassword.do'>忘记密码</a></font>";
			}
		}
	});
}

//测试使用方法
function login2(){
	var param = {"userName":"15002112267","userPassword":"123"};
	var userName = param["userName"];
	if(userName == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	if(param["userPassword"] == ""){
		$("#errmsg").append("<font color=red> 您的密码为空，请仔细填写!</font>");
		$("#userPassword").focus();
		return;
	}
	$.ajax({
		url: path+"/user/login.do",
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				window.location=path+"/user/toMain.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> 用户名或密码错误！</font>";
			}
		}
	});
}

function perDemindCertify(){
	$(".errmsg").empty();
	var param =$.serializeObject($('#perDemindCertifyForm'));
	var userName = param["userName"];
	var userMobile = param["userMobile"];
	var userEmail = param["userEmail"];
	if(userName == ""){
		$("#errmsg_userName2").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	var isMob = isMobile(userMobile);
	var isMail = isEmail(userEmail);
	if(userMobile == ""){
		$("#errmsg_userMobile2").append("<font color=red> 您的电话为空或格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}else if(!isMob){
		$("#errmsg_userMobile2").append("<font color=red> 您的电话格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	if(userEmail == ""){
		$("#errmsg_userEmail2").append("<font color=red> 您的邮箱为空或者格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}else if(!isMail){
		$("#errmsg_userEmail2").append("<font color=red> 您的邮箱格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	if(param["userCertTypeCode"] == "10200"){
		$("#errmsg_userCertTypeCode2").append("<font color=red> 您的证件类型为空，请仔细填写!</font>");
		$("#userCertTypeCode").focus();
		return;
	}
	if(param["userCertNo"] == ""){
		$("#errmsg_userCertNo2").append("<font color=red> 您的证件号码为空，请仔细填写!</font>");
		$("#userCertNo").focus();
		return;
	}
	if(param["userLocationCode"] == "0"){
		$("#errmsg_userLocationCode2").append("<font color=red> 您的所在区域为空，请仔细填写!</font>");
		$("#userLocationCode0").focus();
		return;
	}
	if(param["userAddrDetail"] == ""){
		$("#errmsg_userAddrDetail2").append("<font color=red> 您的详细地址为空，请仔细填写!</font>");
		$("#userAddrDetail").focus();
		return;
	}
	if(param["userCurrPosition"] == ""){
		$("#errmsg_userCurrPosition2").append("<font color=red> 您的当前职务为空，请仔细填写!</font>");
		$("#userCurrPosition").focus();
		return;
	}
	if(param["userWorkYears"] == ""){
		$("#errmsg_userWorkYears2").append("<font color=red> 您的行业工作年限为空，请仔细填写!</font>");
		$("#userWorkYears").focus();
		return;
	}
	isMob = isMobile(param["backupContactPersonMobile"]);
	if(param["backupContactPersonMobile"] == ""){
		$("#errmsg_backupContactPersonMobile2").append("<font color=red> 您的备用联系人电话为空，请仔细填写!</font>");
		$("#backupContactPersonMobile").focus();
		return;
	}else if(!isMob){
		$("#errmsg_backupContactPersonMobile2").append("<font color=red> 您的备用联系人电话格式不正确，请仔细填写!</font>");
		$("#backupContactPersonMobile").focus();
		return;
	}
	if(param["userDesc"] == ""){
		$("#errmsg_userDesc2").append("<font color=red> 您的个人说明为空，请仔细填写!</font>");
		$("#userDesc").focus();
		return;
	}
	if(param["userCertFrontPhotoUrl"] == ""){
		$("#errmsg_userCertFrontPhotoUrlInput2").append("<font color=red> 您的正面证件照没有上传!</font>");
		return;
	}
	if(param["userCertObversePhotoUrl"] == ""){
		$("#errmsg_userCertObversePhotoUrlInput2").append("<font color=red> 您的反面证件照没有上传!</font>");
		return;
	}
	$.ajax({
		url: path+"/user/perDemindCertify.do",
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				window.location=path+"/user/toPerDemindCertifyResult.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>";
			}
		}
	});
}

function comDemindCertify(){
	$(".errmsg").empty();
	var param =$.serializeObject($('#comDemindCertifyForm'));
	var userName = param["userName"];
	var userMobile = param["userMobile"];
	var userEmail = param["userEmail"];
	if(userName == ""){
		$("#errmsg_userName").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	var isMob = isMobile(userMobile);
	if(userMobile == ""){
		$("#errmsg_userMobile").append("<font color=red> 您的电话为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}else if(!isMob){
		$("#errmsg_userMobile").append("<font color=red> 您的电话格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	var isMail = isEmail(userEmail);
	if(userEmail == ""){
		$("#errmsg_userEmail").append("<font color=red> 您的邮箱为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}else if(!isMail){
		$("#errmsg_userEmail").append("<font color=red> 您的邮箱格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	if(param["userCertTypeCode"] == ""){
		$("#errmsg_userCertTypeCode").append("<font color=red> 您的证件类型为空，请仔细填写!</font>");
		$("#userCertTypeCode").focus();
		return;
	}
	if(param["userCertNo"] == ""){
		$("#errmsg_userCertNo").append("<font color=red> 您的证件号码为空，请仔细填写!</font>");
		$("#userCertNo").focus();
		return;
	}
	if(param["orgRegLocationCode"] == "0"){
		$("#errmsg_orgRegLocationCode").append("<font color=red> 您的公司注册所在区域为空，请仔细填写!</font>");
		$("#orgRegLocationCode").focus();
		return;
	}
	if(param["orgCurAddr"] == ""){
		$("#errmsg_orgCurAddr").append("<font color=red> 您的常用地址为空，请仔细填写!</font>");
		$("#orgCurAddr").focus();
		return;
	}
	if(param["userCurrPosition"] == ""){
		$("#errmsg_userCurrPosition").append("<font color=red> 您的当前职务为空，请仔细填写!</font>");
		$("#userCurrPosition").focus();
		return;
	}
	if(param["userDesc"] == ""){
		$("#errmsg_userDesc").append("<font color=red> 您的个人说明为空，请仔细填写!</font>");
		$("#userDesc").focus();
		return;
	}
	if(param["orgName"] == ""){
		$("#errmsg_orgName").append("<font color=red> 您的企业名称为空，请仔细填写!</font>");
		$("#orgName").focus();
		return;
	}
	if(param["orgLawfulManName"] == ""){
		$("#errmsg_orgLawfulManName").append("<font color=red> 您的企业法人名称为空，请仔细填写!</font>");
		$("#orgLawfulManName").focus();
		return;
	}
	if(param["remark"] == ""){
		$("#errmsg_remark").append("<font color=red> 您的备注为空，请仔细填写!</font>");
		$("#remark").focus();
		return;
	}
	
	if(param["orgBusinessCertPhotoNo"] == ""){
		$("#errmsg_orgBusinessCertPhotoNo").append("<font color=red> 您的企业注册号为空，请仔细填写!</font>");
		$("#orgBusinessCertPhotoNo").focus();
		return;
	}
	if(param["orgPhoneNo"] == ""){
		$("#errmsg_orgPhoneNo").append("<font color=red> 您的联系电话为空，请仔细填写!</font>");
		$("#orgPhoneNo").focus();
		return;
	}
	if(param["orgCode"] == ""){
		$("#errmsg_orgCode").append("<font color=red> 您的企业组织机构代码为空，请仔细填写!</font>");
		$("#orgCode").focus();
		return;
	}
	if(param["orgRegCapital"] == ""){
		$("#errmsg_orgRegCapital").append("<font color=red> 您的注册资金为空，请仔细填写!</font>");
		$("#orgRegCapital").focus();
		return;
	}
	
	
	
	if(param["userCertFrontPhotoUrl"] == ""){
		$("#errmsg_userCertFrontPhotoUrl").append("<font color=red> 您的正面证件照没有上传!</font>");
		return;
	}
	if(param["userCertObversePhotoUrl"] == ""){
		$("#errmsg_userCertObversePhotoUrl").append("<font color=red> 您的反面证件照没有上传!</font>");
		return;
	}
	if(param["orgBusinessCertPhotoUrl"] == ""){
		$("#errmsg_orgBusinessCertPhotoUrl").append("<font color=red> 您的营业执照没有上传!</font>");
		return;
	}
	if(param["orgTaxRegCertPhotoUrl"] == ""){
		$("#errmsg_orgTaxRegCertPhotoUrl").append("<font color=red> 您的税务登记证没有上传!</font>");
		return;
	}
	if(param["targets"] == "" || param["targets"] == "[]" || param["targets"] == undefined){
		$("#errmsg_targets").append("<font color=red> 您的税务登记证没有上传!</font>");
		return;
	}
	var targets = param["targets"];
	$.ajax({
		url: path+"/user/comDemindCertify.do?targets=" + targets,
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				window.location=path+"/user/toComDemindCertifyResult.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>";
			}
		}
	});
}

function supplyCertify(){
	$("#errmsg").empty();
	var param =$.serializeObject($('#supplyCertifyForm'));
	if(userName == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
		$("#userName").focus();
		return;
	}
	if(userMobile == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空或格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
//	}else if(!isMobile(userMoblie)){
//		$("#errmsg").append("<font color=red> 您的用户名为空或格式不正确，请仔细填写!</font>");
//		$("#userName").focus();
//		return;
	}
	if(userEmail == ""){
		$("#errmsg").append("<font color=red> 您的用户名为空或者格式不正确，请仔细填写!</font>");
		$("#userName").focus();
		return;
//	}else if(!isEmail(userEmail)){
//		$("#errmsg").append("<font color=red> 您的用户名为空或者格式不正确，请仔细填写!</font>");
//		$("#userName").focus();
//		return;
	}
	if(param["userCertTypeCode"] == ""){
		$("#errmsg").append("<font color=red> 您的证件类型为空，请仔细填写!</font>");
		$("#userCertTypeCode").focus();
		return;
	}
	if(param["userCertNo"] == ""){
		$("#errmsg").append("<font color=red> 您的证件号码为空，请仔细填写!</font>");
		$("#userCertNo").focus();
		return;
	}
	if(param["orgRegLocationCode"] == ""){
		$("#errmsg").append("<font color=red> 您的公司注册所在区域为空，请仔细填写!</font>");
		$("#orgRegLocationCode").focus();
		return;
	}
	if(param["orgRegAddr"] == ""){
		$("#errmsg").append("<font color=red> 您的详细地址为空，请仔细填写!</font>");
		$("#orgRegAddr").focus();
		return;
	}
	if(param["userCurrPosition"] == ""){
		$("#errmsg").append("<font color=red> 您的当前职务为空，请仔细填写!</font>");
		$("#userCurrPosition").focus();
		return;
	}
	if(param["orgName"] == ""){
		$("#errmsg").append("<font color=red> 您的企业名称为空，请仔细填写!</font>");
		$("#orgName").focus();
		return;
	}
	if(param["orgLawfulManName"] == ""){
		$("#errmsg").append("<font color=red> 您的企业法人名称为空，请仔细填写!</font>");
		$("#orgLawfulManName").focus();
		return;
	}

	if(param["orgBusinessCertPhotoUrl"] == ""){
		$("#errmsg").append("<font color=red> 您的营业执照没有上传!</font>");
		return;
	}


	var targets = param["targets"];
	$.ajax({
		url: path+"/user/supplyCertify.do?targets=" + targets,
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				window.location=path+"/user/toSupplyCertifyResult.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>";
			}
		}
	});
}

function convert(){
	alert("convert function");
	$("#errmsg").empty();
	var param =$.serializeObject($('#pointForm'));
	
	if(param["point"] == ""){
		$("#errmsg").append("<font color=red> 请输入要转换的积分!</font>");
		return;
	}

	var point = param["point"];
	$.ajax({
		url: path+"/user/pointConvertCash.do?point=" + point,
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				alert("convert success");
				window.location=path+"/user/toIndividual.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>";
			}
		}
	});
}

function accountBankCardAdd(){
	$("#errmsg").empty();
	var param =$.serializeObject($('#userBankCardForm'));
	var bankCardNo = param["bankCardNo"]
	if(bankCardNo == ""){
		$("#errmsg").append("<font color=red> 您的银行卡号码为空，请仔细填写!</font>");
		$("#bankCardNo").focus();
		return;
//	}else{
//		if(!isMobile(userName) && !isEmail(userName)){
//			$("#errmsg").append("<font color=red> 您的用户名格式不正确，请仔细填写!</font>");
//			$("#userName").focus();
//			return;
//		}
	}
	var bankName = param["bankName"];
	if(bankName == ""){
		$("#errmsg").append("<font color=red> 您的银行名称为空，请仔细填写!</font>");
		$("#bankName").focus();
		return;
	}
	$.ajax({
		url: path+"/user/accountBankCardAdd.do",
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				window.location=path+"/user/accountBankCardAddSuccess.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>";
			}
		}
	});
}

function withdraw(){
	$("#errmsg").empty();
	var param =$.serializeObject($('#withdrawForm'));
	var bankCardNo = param["bankCardNo"]
	var num = param["num"]
	var card = param["card"];
	alert("num:" + num + " card:" + card);
	if(num == ""){
		$("#errmsg").append("<font color=red> 请填写提现金额!</font>");
		$("#num").focus();
		return;
//	}else{
//		if(!isMobile(userName) && !isEmail(userName)){
//			$("#errmsg").append("<font color=red> 您的用户名格式不正确，请仔细填写!</font>");
//			$("#userName").focus();
//			return;
//		}
	}
	if(card == "0"){
		$("#errmsg").append("<font color=red> 请选择银行卡!</font>");
		$("#card").focus();
		return;
	}
	var url = encodeURI("/user/withdraw.do?num=" + num + "&card=" + card);
	window.location=path+url;
			
}

function searchPremChange(){
	var dateTime1=$("#appDateTime2").attr("value");
	var dateTime2=$("#appDateTime").attr("value");
	var type = $("#type").attr("value");
	var url = encodeURI("/user/searchPremChange.do?dateTime1=" + dateTime1 + "&dateTime2=" + dateTime2 + "&type=" + type);
	window.location=path+url;
}
//手机邮箱的更新及添加功能请求
function changeME(i){
	$("#errmsg2").empty();
	var url = "";
	var param =$.serializeObject($('#changeForm'));
	if(i==1){
		var userMobile2 = param["userMobile2"];
		var userMobile3 = param["userMobile3"];
		var verifyMobileCode = param["verifyMobileCode"];
		url="?userMobile2="+userMobile2+"&userMobile3="+userMobile3+"&verifyMobileCode="+verifyMobileCode+"&i="+i;
	}else if(i==2){
		var userMobile3 = param["userMobile3"];
		url="?userMobile3="+userMobile3+"&verifyMobileCode="+verifyMobileCode+"&i="+i;
	}else if(i==3){
		var userEmail2 = param["userEmail2"];
		var userEmail3 = param["userEmail3"];
		url="?userEmail2="+userEmail2+"&userEmail3="+userEmail3+"&i="+i;
	}else if(i==4){
		var userEmail3 = param["userEmail3"];
		url="?userEmail3="+userEmail3+"&i="+i;
	}else{
		alert("不可能弹出的框！");
	}

//	var userName = param["userName"]
//	if(userName == ""){
//		$("#errmsg").append("<font color=red> 您的用户名为空，请仔细填写!</font>");
//		$("#userName").focus();
//		return;
//	}
	$.ajax({
		url: path+"/user/changeME.do"+url,
		data: param,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				window.location=path+"/user/toInformationBasic.do";
			}else{
				document.getElementById('errmsg').innerHTML = "<font color=red> " + result.msg + "</font>";
			}
		}
	});
}

function sysCancel(){
	$("#errmsg").empty();
	document.getElementById("adminLoginForm").reset();
}
//模型点赞功能
function modelGood(a){
	$.ajax({
		url: path+"/model/modelGood.do?modelId=" + a,
		data: a,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				location.reload();
			}else{
				alert(result.msg);
			}
		}
	});
}
//收藏模型功能
function modelCollect(a){
	$.ajax({
		url: path+"/model/modelCollect.do?modelId=" + a,
		data: a,
		type : "POST",
		dataType: "json",
		success: function(result) {
			if(result.success){
				location.reload();
			}else{
				alert(result.msg);
			}
		}
	});
}
//收藏模型功能
function modelDownload(a){
	window.location=path+"/model/modelDownload.do?modelId=" + a;
	
}
